package com.rymcu.subject.service.impl;

import com.rymcu.subject.entity.SignCharData;
import com.rymcu.subject.entity.SubjectAnswerRecord;
import com.rymcu.subject.mapper.SubjectAnswerRecordMapper;
import com.rymcu.subject.service.SubjectAnswerRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class SubjectAnswerRecordServiceImpl implements SubjectAnswerRecordService {

    @Resource
    private SubjectAnswerRecordMapper subjectAnswerRecordMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return subjectAnswerRecordMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(SubjectAnswerRecord record) {
        return subjectAnswerRecordMapper.insert(record);
    }

    @Override
    public int insertSelective(SubjectAnswerRecord record) {
        return subjectAnswerRecordMapper.insertSelective(record);
    }

    @Override
    public SubjectAnswerRecord selectByPrimaryKey(Long id) {
        return subjectAnswerRecordMapper.selectByPrimaryKey(id);
    }

    /**
     * 是否存在指定日期指定类型答题记录
     *
     * @param userId
     * @param now
     * @param everydayFlag
     * @return
     */
    @Override
    public boolean existsAnswerRecord(
            long userId,
            Date now,
            boolean everydayFlag
    ) {
        return subjectAnswerRecordMapper.existsAnswerRecord(userId, now, everydayFlag);
    }

    @Override
    public List<SignCharData> listSignChartData(
            long userId,
            Date now
    ) {
        return subjectAnswerRecordMapper.listSignChartData(userId, now);
    }

}
